<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>					

<title>Geo-fence</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" media="all" href="sysgeofence_edit.php_files/style.css">
</head><body bgcolor="#ffffff">
<br>
<script>
function trans_pos(pos)
{
	var data1 = parseInt(pos) * 100;
	var data2 = (pos - parseInt(pos)) * 60;
	return parseFloat(data1 + data2).toFixed(4);
}

function trans_lat(data)
{
	data = trans_pos(data);
	if (data < 0)
	{
		return (data * (-1)) + ",S";
	}
	else
	{
		return data + ",N";
	}
}

function trans_lng(data)
{
	data = trans_pos(data);
	if (data < 0)
	{
		return (data * (-1)) + ",W";
	}
	else
	{
		return data + ",E";
	}
}

function check_value()
{
	var enterValue = -1;
　　var enterArray = document.getElementsByName("enter");
　　for(i=0;i<enterArray.length;i++)
　　{
    　　 if(enterArray[i].checked)
       　　enterValue=enterArray[i].value;
　　}
	if (enterValue == -1)
	{
		return true;
	}
	var data_value = document.control.data.value;
	var data_array = data_value.split(";");
	if (data_array.length != 2)
	{
		alert('error');
		return false;
	}
	
	var start_array = data_array[0].split(",");
	if (start_array.length != 2)
	{
		alert('error');
		return false;
	}
	
	var end_array = data_array[1].split(",");
	if (end_array.length != 2)
	{
		alert('error');
		return false;
	}
		
	var value = trans_lng(start_array[0]) + "," + trans_lat(start_array[1]) + "," + trans_lng(end_array[0]) + "," + trans_lat(end_array[1]);
	// alert(value);
	document.control.data.value = value;
	
	return true;
}
</script>
<table class="tableBorder" align="center" border="1" cellpadding="5" cellspacing="0" width="550">
<tbody><tr>
</tr></tbody><caption>Geo-fence</caption>

<form id="control" name="control" method="post" action="/sysgeofence_edit.php" onsubmit="return check_value()"></form>

  <tbody><tr>
    <th>Tracker ID:</th>
    <td>8613570004900&nbsp;</td>
  </tr>
  <tr>
  	<th>Name:</th>
	<td><input name="name" size="30" value=""></td>
  </tr><tr>
  	<th valign="top">Select range from map:</th>
	<script>
	function restoreRange(str)
	{
		//window.parent.popupMask.style.display = "block";
		//window.parent.popupContainer.style.display = "block";
		window.parent.document.getElementById('popupMask').style.display = "block";
		window.parent.document.getElementById('popupContainer').style.display = "block";
		
		document.control.data.value = str;
		// alert(str);
	}
	function selectRange()
	{
		window.parent.document.getElementById('popupMask').style.display = "none";
		window.parent.document.getElementById('popupContainer').style.display = "none";
	
		var g_map = window.parent.g_map;
		
		window.parent.selectRangeOnMap(restoreRange);		
	}
	</script>
	<td><input name="data" size="50" value="">&nbsp;&nbsp;<br><br><input value="Select range from map" onclick="selectRange();" readonly="1" type="button">&nbsp;&nbsp;<br>Mouse left click on the map, after choose the range then left click again.<br><br></td>
  </tr>
  <tr>
    <th valign="top">Alarm when:</th>
    <td>
	<select name="condition" id="condition">
			<option value="0" selected="selected">Leave this range</option>
			<option value="1">Enter this range</option>
		</select>
	</td>
  </tr>
  <tr>
    <th valign="top">State:</th>
    <td>
	<select name="state" id="state">
			<option value="0">Disable</option>
			<option value="1" selected="selected">Enable</option>
		</select>
	</td>
  </tr>  
</tbody></table>
<br><br>
<table align="center" width="150">
	<tbody><tr>
		<td align="left">
			<input onclick="window.location.href='sysgeofence.php?uin=8613570004900'" value="&nbsp;&nbsp;Back&nbsp;&nbsp;" type="button">
		</td>
		<td align="right">
      <input name="cmd" value="4" type="hidden">
	  <input name="id" value="0" type="hidden">
	  <input name="uin" value="8613570004900" type="hidden">
      <input name="Submit" value="Submit" type="submit">
	  <input name="action" value="submitted" type="hidden">	  
		</td>
	</tr>
	
</tbody></table>		

</body><div FirebugVersion="1.3.3" style="display: none;" id="_firebugConsole"></div></html>